﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
using qiupeng.Public;
using System.IO;

public partial class Agenciestable :Base 
{
    Db List = new Db();
    public static string showtitle;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string SQL_GetList1 = "select top 1 bmqx from qp_Hr_username where 1=1 ";
            OleDbDataReader MyReader1 = List.GetList(SQL_GetList1);

            string strqx = "";
            while (MyReader1.Read())
            {
                strqx = MyReader1["bmqx"].ToString();
            }

            List.QuanXianVis(ListTreeView, "aaaa1a", Session["perstr"].ToString());

            BindTree(ListTreeView.Nodes, 0,"");
            string SQL_GetList = "select id,jgname from qp_hr_JiGou ";
            OleDbDataReader MyReader = List.GetList(SQL_GetList);
            if (MyReader.Read())
            {
                showtitle = "";
            }
            else
            {
                showtitle = "<a href='JiGouManage/JgMain.aspx?id=10000' target='rform'>增加公司/部门</a>";
            }
            MyReader.Close();

        }









    }

    private void BindTree(TreeNodeCollection Nds, int IDStr,string qx)
    {

       

        if (IDStr == 0)
        {
            TreeNode OrganizationNode = new TreeNode();


            OrganizationNode.Value = "23";
            int strId = 23;
            OrganizationNode.ImageUrl = "images/menu/zhu.gif";
            OrganizationNode.Text = " <a href='JiGouManage/JgMain.aspx?id=23' target='rform' onclick='parent.UploadComplete();' >企业</a>";
            //OrganizationNode.NavigateUrl = "JiGouManage/JgMain.aspx?id=" + strId + "";



            OrganizationNode.Expanded = true;
            OrganizationNode.SelectAction = TreeNodeSelectAction.None;


            OrganizationNode.Target = "rform";
            Nds.Add(OrganizationNode);
            BindTree(Nds[Nds.Count - 1].ChildNodes, strId, qx);
        }
        else
        {
            string SQL_GetList = "select id,jgname from qp_hr_JiGou where ParentNodesID=" + IDStr.ToString() + "  ";

            if (qx != "")
            {
                SQL_GetList += " and id in (" + qx + ") ";
            }
            SQL_GetList += "  order by paixu,id asc ";

            OleDbDataReader MyReader = List.GetList(SQL_GetList);
            while (MyReader.Read())
            {
                TreeNode OrganizationNode = new TreeNode();

                OrganizationNode.Value = MyReader["ID"].ToString();
                int strId = int.Parse(MyReader["ID"].ToString());
                OrganizationNode.ImageUrl = "images/menu/homepage.gif";
                OrganizationNode.Text = " <a href='JiGouManage/JgMain.aspx?id=" + strId + "' target='rform' onclick='parent.UploadComplete();' >" + MyReader["JgName"].ToString() + "</a>";

                // OrganizationNode.NavigateUrl = "JiGouManage/JgMain.aspx?id=" + strId + "";
                OrganizationNode.Expanded = false;



                OrganizationNode.SelectAction = TreeNodeSelectAction.None;

                OrganizationNode.Target = "rform";
                Nds.Add(OrganizationNode);
                BindTree(Nds[Nds.Count - 1].ChildNodes, strId, qx);
            }
            MyReader.Close();
        }
       

    }
}
